package com.bgds.sys.task;

import com.bgds.sys.api.service.DeTongService;
import com.bgds.sys.common.utils.ResultUtil;
import com.bgds.sys.module.controller.BaseBaoxing;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @author Smiling
 * @description: 助燃风机总貌推送任务(振动)
 * @date 2021/5/24  22:16
 */
@Component
public class CombustionSupportingFanJob implements Job {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;
    @Autowired
    private DeTongService deTongService;
    @Autowired
    private BaseBaoxing baseBaoxing;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
        String relationId = dataMap.get("relationId").toString();
        String deviceCode = dataMap.get("deviceCode").toString();
        String id = dataMap.get("id").toString();
        Map map = new HashMap();
        map.put("baoxing", baseBaoxing.all(deviceCode));
        map.put("detong", baseBaoxing.getObject(relationId, 107));
        messagingTemplate.convertAndSendToUser(id, "/combustion_support_fan", new ResultUtil<>().setData(map));
    }
}